﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Abp.AspNetCore.Mvc.Extensions;
using Abp.Auditing;
using Abp.Web.Models;
using FwProject.Controllers;
using FwProject.Statistics;
using FwProject.Statistics.Dto;
using Microsoft.AspNetCore.Mvc;

namespace FwProject.Web.Shop.Controllers
{
    /// <summary>
    /// 统计
    /// </summary>
    public class StatisticsController : FwProjectControllerBase
    {
        private readonly IStatisticsAppService _statisticsAppService;
        public StatisticsController(IStatisticsAppService statisticsAppService)
        {
            _statisticsAppService = statisticsAppService;
        }
        /// <summary>
        /// 销售收入统计
        /// </summary>
        /// <returns></returns>
        public async Task<IActionResult> SalesRevenue(int? id, DateTime? orderTime)
        {
            int pageNumber = id ?? 1;
            if (!orderTime.HasValue)
                orderTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM"));

            var data = await _statisticsAppService.GetSalesRevenueDataAsync(pageNumber, 10, orderTime.Value);

            if (Request.IsAjaxRequest())
            {
                return PartialView("SalesRevenuePartial", data);
            }

            return View(data);
        }

        /// <summary>
        /// 热卖商品统计
        /// </summary>
        /// <returns></returns>
        public IActionResult HotSaleItem()
        {
            return View();
        }

        //[HttpGet]
        //[DisableAuditing]
        //[WrapResult(false, false)]//关闭ABP的返回数据封装
        //public async Task<IActionResult> GetHotSaleItemData(int page, int limit, HotSaleItemFilter filter)
        //{
        //    var data=await 
        //}
    }
}